<template>
	<view class="page" :style="themeColor">
		<view class="flex benben-position-layout flex flex-wrap align-center platformMessage_flex_0"
			:style="{height:(64+StatusBarRpx)+'rpx',paddingTop:StatusBarRpx+'rpx'}">
			<view class='flex align-center justify-between platformMessage_fd0_0'>
				<view class='flex flex-wrap align-center platformMessage_fd0_0_c0' @tap.stop="handleJumpDiy"
					data-type="back" data-url="1">
					<text class='fu-iconfont2  platformMessage_fd0_0_c0_c0'>&#xE794;</text>
				</view>
				<view class='flex align-center'>
					<view class="platformMessage_fd0_0_c1_c0">{{title}}</view>
					<!-- <text>Faker's Triumph at the 2023 League of Legends World Championship: The Icons of Esports</text> -->
				</view>
				<view class='flex flex-wrap align-center platformMessage_fd0_0_c0'></view>
			</view>

		</view>
		<view :style="{height: (64+StatusBarRpx)+'rpx'}"></view>
		<view class="loading_css" v-if="isShow">
			<uv-loading-icon size="24" mode="circle" color="#4087FD" :show="true"></uv-loading-icon>
			<view>加载中</view>
		</view>
		<block v-else>
			<view class="flex flex-direction align-stretch benben-flex-layout platformMessage_flex_1">
				<view class="intensify" @tap.stop="handleJumpDiy" data-type="navigateTo"
					:data-url="`/pages/index/englishSpeech/speechDetails`">
					<view class="intensify_item">
						<view class="item_content">
							<view class="item_text">
								<view class="item_content_2">
									单词数量{{detailsInfo.tatol_num}}个 l 已过{{detailsInfo.cross_num}}个 l  剩余{{detailsInfo.not_num}}
								</view>
							</view>
						</view>
					</view>
				</view>
				<view class="word">
					<view class="word_item" v-for="(item, index) in paragraph_data" :key="index">
						<text v-for="(v, k) in item.word_info" :key="k">
							<text class="word_item_text" v-if="v.color == 1">{{v.word}}</text>
							<text class="word_learned" v-if="v.color == 2">{{v.word}}</text>
							<text class="word_yellow" v-if="v.color == 3">{{v.word}}</text>
						</text>

					</view>
				</view>

			</view>
			<view class="btn">
				<view class="btn_view" @tap.stop="startedTrain">开始选词训练</view>
			</view>
		</block>

		<view style="height: 110rpx;"></view>

		<uv-overlay :show="show">
			<view class="warp">
				<view class="rect">
					<view class="video_text">
						<view class="video_text_1" v-if="status == 1">当前演讲中有未完成的训练</view>
						<view class="video_text_2" v-if="status == 1">请继续完成训练</view>
						<view class="video_text_1" v-if="status == 2">当前演讲中有未完成的检测</view>
						<view class="video_text_2" v-if="status == 2">请继续完成检测</view>
					</view>
					<view class="input_bottom">
						<view class="input_bottom_1" @click="show = false">取消</view>
						<view class="input_bottom_2" v-if="status == 1" @click="confirm">继续训练</view>
						<view class="input_bottom_2" v-if="status == 2" @click="confirm">继续检测</view>
					</view>
				</view>
			</view>
		</uv-overlay>
	</view>
</template>
<script>
	import {
		validate
	} from '@/common/utils/validate.js'
	export default {
		components: {},


		data() {
			return {
				"aid": "", // 详情id
				"title": "",
				"isShow": true,
				"detailsInfo": {},
				"paragraph_data": [], // 单词列表
				"status": 0, // 0 不跳转  1待训练   2待检测
				"record_id": "", // 记录id
				"show": false,
			};
		},
		computed: {
			themeColor() {
				return this.$store.getters.themeColor
			},

		},
		watch: {},
		onLoad(options) {
			let {
				aid,
				title
			} = options
			if (aid !== undefined) this.aid = aid;
			if (title !== undefined) this.title = title;
			console.log(this.title);

		},
		onUnload() {

		},
		onReady() {

		},
		onShow() {
			this.getDetails();
			this.getDetection();
		},
		onHide() {

		},
		onResize() {

		},
		onPullDownRefresh() {

		},
		onReachBottom(e) {

		},
		onPageScroll(e) {

		},
		methods: {
			getDetails() {
				this.$api.post(global.apiUrls.post65572db24cbe5, {
					speechlist_id: this.aid
				}).then(res => {
					// console.log(res);
					this.isShow = false;
					if (res.data.code == 1) {
						this.detailsInfo = res.data.data;
						this.paragraph_data = res.data.data.paragraph_data;
					} else {
						this.$message.info(res.data.msg);
					}
				})
			},
			// 检测  post65646c043f89b
			getDetection() {
				this.$api.post(global.apiUrls.post65646c043f89b, {
					speechlist_id: this.aid
				}).then(res => {
					// console.log(res);
					if (res.data.code == 1) {
						this.status = res.data.data.status;
						this.record_id = res.data.data.record_id;
					} else {
						this.$message.info(res.data.msg);
					}
				})
			},
			startedTrain() {
				if (this.status == 0) {
					uni.navigateTo({
						url: '/pages/index/englishSpeech/startedTrain?aid=' + this.aid + '&title=' + this.title
					})
				} else {
					this.show = true;
				}
			},
			confirm() {
				this.show = false;
				if (this.status == 1) {
					uni.navigateTo({
						url: '/pages/index/englishSpeech/trainNow?record_id=' + this.record_id + '&is_train=2'
					})
				} else if (this.status == 2) {
					uni.navigateTo({
						url: '/pages/index/englishSpeech/detection?record_id=' + this.record_id
					})
				}
			},
		}
	};
</script>
<style lang="scss" scoped>
	.warp {
		display: flex;
		align-items: center;
		justify-content: center;
		height: 100%;
	}

	.rect {
		width: 450rpx;
		height: 269rpx;
		border-radius: 10rpx;
		background-color: #fff;
		text-align: center;
		position: relative;
	}

	.input_bottom {
		position: absolute;
		bottom: 0;
		left: 0;
		width: 100%;
		border-top: 1px solid #dddddd;
		padding: 20rpx;
		display: flex;
		justify-content: space-between;

		.input_bottom_1 {
			width: 50%;
			text-align: center;
			font-size: 25rpx;
			color: #999999;
		}

		.input_bottom_2 {
			width: 50%;
			text-align: center;
			font-size: 25rpx;
			color: #4087FD;
		}
	}

	.video_text {
		padding: 58rpx 0 0;
		text-align: center;

		.video_text_1 {
			font-size: 25rpx;
			font-family: PingFang SC, PingFang SC;
			font-weight: 400;
			color: #333333;
		}

		.video_text_2 {
			font-size: 25rpx;
			font-family: PingFang SC, PingFang SC;
			font-weight: 400;
			color: #333333;
			margin-top: 12rpx;
		}

		.video_text_3 {
			position: absolute;
			bottom: 0;
			left: 0;
			width: 100%;
			border-top: 1px solid #dddddd;
			padding: 20rpx;
			color: #4087FD;
			font-size: 25rpx;
		}
	}


	.btn {
		width: 100%;
		position: fixed;
		bottom: 0;
		padding: 0 25rpx 35rpx;

		.btn_view {
			width: 100%;
			height: 68rpx;
			line-height: 68rpx;
			text-align: center;
			color: #fff;
			font-size: 25rpx;
			background: #4087FD;
			border-radius: 34px 34px 34px 34px;
		}
	}

	.word {
		margin: 15rpx 25rpx 0;
		background: #fff;
		border-radius: 10rpx;
		padding: 13rpx 20rpx;

		.word_item {
			padding: 13rpx 0;
			line-height: 30rpx;
			overflow: hidden;
			word-break: keep-all;

			.word_item_text {
				float: left;
				padding: 5rpx 10rpx;
				font-size: 25rpx;
			}

			.word_learned {
				float: left;
				padding: 5rpx 10rpx;
				font-size: 25rpx;
				color: #4DC777;
			}

			.word_yellow {
				float: left;
				padding: 5rpx 10rpx;
				font-size: 25rpx;
				color: #FFA200;
			}
		}
	}

	.intensify {
		margin: 15rpx 25rpx 0;
		background: #fff;
		border-radius: 10rpx;

		.intensify_item {
			padding: 20rpx;
			width: 100%;
			// border-bottom: 1px solid #eee;
			.item_title {
				width: 100%;
				display: flex;
				align-items: center;
				justify-content: space-between;
				font-size: 20rpx;
				font-family: PingFang SC, PingFang SC;
				font-weight: 400;
				color: #333333;

				.date_text {
					width: 100%;
					font-size: 18rpx;
					font-family: PingFang SC, PingFang SC;
					font-weight: 400;
					color: #999999;
				}
			}

			.item_content {
				display: flex;
				align-items: center;

				.item_num {
					width: 55rpx;
					height: 55rpx;
					background: #f8f8f8;
					border-radius: 50%;
					position: relative;

					.item_num_img {
						width: 28rpx;
						height: 28rpx;
						position: absolute;
						left: 50%;
						top: 50%;
						transform: translate(-50%, -50%);
					}

					.item_num_text {
						font-size: 13rpx;
						font-weight: bold;
						line-height: 52rpx;
						text-align: center;
						color: #fff;
						position: relative;
						z-index: 10;
					}
				}

				.item_text {
					width: 100%;
					.item_content_1 {
						font-size: 20rpx;
						font-family: PingFang SC, PingFang SC;
						font-weight: 400;
						color: #333333;
					}

					.item_content_2 {
						width: 100%;
						font-size: 18rpx;
						color: #333333;
					}
				}

			}
		}
	}

	.tabs {
		width: 100%;
		display: flex;
		align-items: center;
		justify-content: space-between;
		padding: 0rpx 135rpx;

		.tabs_item {
			font-size: 20rpx;
			font-family: PingFang SC, PingFang SC;
			font-weight: 400;
			color: #333333;
			padding: 20rpx 0;
			position: relative;
		}

		.active_item {
			color: #4087FD;
			font-weight: bold;
		}

		.tabs_line {
			display: inline-block;
			width: 31rpx;
			height: 5rpx;
			background: #4087FD;
			border-radius: 6rpx;
			position: absolute;
			left: 50%;
			bottom: 0;
			transform: translateX(-50%);
		}
	}

	.content_img {
		width: 100%;
		height: 219rpx;
		margin-top: 20rpx;

		image {
			width: 100%;
			height: 100%;
			border-radius: 10rpx;
		}
	}

	.page {
		width: 100vw;
		overflow-x: hidden;
		min-height: calc(100vh - var(--window-bottom));
		background: rgba(248, 248, 248, 1);
		background-size: 100% auto !important;
	}

	.platformMessage_flex_0 {
		background: #fff;
		width: 100%;
		height: 64rpx;
		overflow: hidden;
		z-index: 10;
		top: 0rpx;
		background-size: 100% auto !important;
	}

	.platformMessage_fd0_0_c1_c0 {
		width: 100%;
		font-size: 25rpx;
		font-weight: 500;
		color: #333333;
		line-height: 64rpx;
		display: -webkit-box;
		-webkit-line-clamp: 1;
		-webkit-box-orient: vertical;
		overflow: hidden;
	}

	.platformMessage_fd0_0_c0_c0 {
		font-size: 25rpx;
		color: #333;
	}

	.platformMessage_fd0_0_c0 {
		width: 50rpx;
		height: 50rpx;
	}

	.platformMessage_fd0_0 {
		padding: 0rpx 25rpx 0rpx 25rpx;
		width: 100%;
	}

	.platformMessage_flex_1 {
		// margin: 16rpx 25rpx 16rpx 25rpx;
		// background: #fff;
		// border-radius: 10rpx;
	}

	.platformMessage_fd1_0_c2 {
		font-size: 18rpx;
		font-family: PingFang SC, PingFang SC;
		font-weight: 400;
		color: #999999;
		line-height: 25rpx;
	}

	.platformMessage_fd1_0_c1 {
		margin: 10rpx 0rpx 0rpx 0rpx;
		font-size: 18rpx;
		font-family: PingFang SC, PingFang SC;
		font-weight: 400;
		color: #999999;
		line-height: 26rpx;
		// -webkit-line-clamp: 2;
		// overflow: hidden;
		// text-overflow: ellipsis;
		// display: -webkit-box;
		// -webkit-box-orient: vertical;
	}

	.platformMessage_fd1_0_c0 {
		font-size: 20rpx;
		font-family: PingFang SC, PingFang SC;
		font-weight: 400;
		color: #333333;
		// line-height: 45rpx;
		// -webkit-line-clamp: 1;
		// overflow: hidden;
		// text-overflow: ellipsis;
		// display: -webkit-box;
		// -webkit-box-orient: vertical;
	}

	.platformMessage_fd1_0 {
		// background: #fff;
		width: 100%;
		padding: 20rpx 25rpx 20rpx 25rpx;
		border-bottom: 1px solid #eee;
	}
</style>